const KoaRouter = require('@koa/router')

const {fileUpload,getFileName,deleteFile,getFileList,download,createMkdir,mergeFiles,uploadAvatar} = require('../middleware/file.js')
const {validateAuth} = require("../middleware/login.js");
const {upload,success} = require("../controller/user.js");

const userRouter = new KoaRouter({prefix: '/file'})

userRouter.post('/uploadAvatar',uploadAvatar,upload)

userRouter.get('/finishChunk',getFileName)
userRouter.post('/bigFileUpload',validateAuth,createMkdir,fileUpload,success)
userRouter.get('/mergeFile',validateAuth,mergeFiles,upload)
userRouter.get('/fileList',validateAuth,getFileList)

userRouter.get('/download',validateAuth,download)
userRouter.get('/deleteFile',validateAuth,deleteFile)


module.exports = userRouter
